<?php namespace App\Admin\Goods\JmThemeGoods\Listeners;

use App\Core\Exceptions\InputError;
use App\Core\Service\Listeners\CreateListener as Base;
use Input;
use DB;

class CreateListener extends Base {
    
    public function onCreateSaving(){
        $goods_id = Input::get('goods_id');
        $theme_id = Input::get('theme_id');
        if(!$goods_id || !$theme_id){
            throw new InputError('参数有误');
            return ;
        }
        $goods = DB::table('jimiao_theme_goods')
            ->where('theme_id','=',$theme_id)
            ->where('goods_id','=',$goods_id)
            ->where('is_delete','=','0')
            ->first();
        if($goods){
            throw new InputError('商品已存在');
            return;
        }
    }
}